<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>系统首页</title>
	<link rel="stylesheet" href="/hyqcss/public.css">
	<style type="text/css">
		*{
			margin: 0;
			padding: 0;
		}
		body{
			font-family: "Microsoft YaHei";
			background: #e9e9e9;
		}
		h1,h2,h3,h4,h5,h6,b{
			font-weight: normal;
		}
		li{
			list-style: none;
		}
		a{
			text-decoration: none;
		}
		.must-h:before{
			content: "* ";
			color: red;
		}
		.main-title-h2-h{
			color: #999;
			margin-top: 14px;
			padding: 8px 40px;
			line-height: 25px;
			font-size: 18px;
			border-bottom: 1px solid #ececec;
			background: #fff;
		}
		.main-container-h{
			padding: 0 40px;
		}
		.title-h{
			border-left: 5px solid #1188f6;
			padding-left: 7px;
			margin-top: 30px;
			margin-bottom: 10px;
			line-height: 16px;
			color: #676a6c;
			font-size: 13px;
		}
		.form-row-h{
			margin-top: 20px;
			color: #333;
		}
		.label-required-h{
			width: 115px;
			text-align: right;
			height: 30px;
			line-height: 30px;
			margin: 0;
			padding: 0;
			font-size: 14px;
			color: #000;
			font-weight: 400;
		}
		.input-required-h{
			margin-left: 20px;
			width: 437px;
			font-size: 14px;
			color: #333;
			font-weight: 400;
			border: 1px solid #eee;
			height: 30px;
			padding: 0 10px;
		}
		.tips-h{
			font-size: 12px;
			color: #999;
		}
		/*----------------button公共部分----------------*/
		.form-btn-container-h{
			
		}
		.btn-h{
			box-sizing: border-box;
			height: 32px;
			min-width: 90px;
			font-size: 14px;
			display: inline-block;
			text-align: center;
			border-radius: 2px;
			border: none;
			line-height: 32px;
			outline: none;
			color: #fff;
			width: 90px;
			cursor: pointer;
		}
		.btn-success-h{
			background: #1E9FFF;
		}
		.btn-warning-h{
			background: #f0ad4e;
		}
		.btn-danger-h{
			background: #f0ad4e;
		}
		.btn-default-h{
			background: #fff;
			color: #333 !important;
			border: 1px solid #ddd !important;
		}
		/*-----------flex公共部分----------*/
		.flex-h{
			display: flex;
		}
		.flex-d-col-h{
			flex-direction: column;
		}
		.flex-ai-center-h{
			align-items: center;
		}
		/*----------------内边距外边距公共部分-----------------*/
		.pl-130-h{
			padding-left: 130px!important;
		}
		.pb-100-h{
			padding-bottom: 100px!important;
		}
		.pt-40-h{
			padding-top: 40px!important;
		}
		.mat-20-h{
			margin-top: 20px !important;
		}
		.mal-20-h{
			margin-left: 20px !important;
		}
		.mar-10-h{
			margin-right: 10px !important;
		}
		.mar-20-h{
			margin-right: 20px !important;
		}

	</style>
</head>
<body>
	<!-- 顶部提示框 开始 -->
	<div class="public_tipSetting_contaienr">
		<div class="public_tipSetting_content">
			<p>只有正确配置基本信息后，才能正常使用其他功能，可参考右侧教程。</p>
			<a href="https://support.qq.com/products/174823/faqs/69544" target="_blank">查看教程</a>
			<svg t="1599462804099" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8813" width="15" height="15"><path d="M512 102.4a409.6 409.6 0 1 0 409.6 409.6 409.6 409.6 0 0 0-409.6-409.6z m181.248 518.144a51.2 51.2 0 0 1-72.704 72.704L512 584.192l-108.544 109.056a51.2 51.2 0 0 1-72.704-72.704L439.808 512 330.752 403.456a51.2 51.2 0 0 1 72.704-72.704L512 439.808l108.544-109.056a51.2 51.2 0 0 1 72.704 72.704L584.192 512z" fill="" p-id="8814"></path></svg>
		</div>
	</div>
	<!-- 顶部提示框 结束 -->
	<div style="background: #fff; margin: 0 20px;">
		<h2 class="main-title-h2-h">设置</h2>
		<form method="post" action="" id="form1">
		<div class="main-container-h">
			<h4 class="title-h">基本配置</h4>
			<div class="flex-h form-row-h">
				<label class="label-required-h must-h">企业名称:</label>
				{$qyConfig->text('corp_name','class="input-required-h" placeholder="企业名称" required="required"')}
			</div>
			<div class="flex-h form-row-h">
				<label class="label-required-h must-h">企业ID(CorpID):</label>
				<!-- {if $qyConfig->corp_id}
				{$qyConfig->text('corp_id','class="input-required-h" placeholder="企业ID" disabled')}
				{else}
				{$qyConfig->text('corp_id','class="input-required-h" placeholder="企业ID" required="required"')}
				{/if} -->
				{$qyConfig->text('corp_id','class="input-required-h" placeholder="企业ID" required="required" disabled')}
				<span class="btn-h btn-success-h mar-20-h" id="one" onclick="upd()" >修改</span>
				<span class="btn-h btn-danger-h mar-20-h" id="tow" onclick="upd_d()" style="display: none;">提交</span>
			</div>
			<div class="flex-h form-row-h">
				<label class="label-required-h must-h">客户联系Secret:</label>
				{$qyConfig->text('externalcontact_secret','class="input-required-h" placeholder="客户联系Secret" required="required"')}
			</div>
			<div class="flex-h form-row-h">
				<label class="label-required-h must-h">通讯录Secret:</label>
				{$qyConfig->text('user_secret','class="input-required-h" placeholder="通讯录Secret" required="required"')}
			</div>
		</div>
		<div class="main-container-h">
			<h4 class="title-h">客户联系接收事件服务器配置</h4>
			<div class="flex-h form-row-h">
				<label class="label-required-h">URL:</label>
				<input type="text" id="eUrl" class="input-required-h" value="{$h->get_http_server_name()}/Addons/QyWechat/Api/Callback/Externalcontact/index.html" readonly/>
				<span class="btn-h btn-success-h mar-20-h" onclick="ecopyUrl()">复制</span>
			</div>
			<div class="flex-h form-row-h">
				<label class="label-required-h">Token:</label>
				<input type="text" id="eToken" class="input-required-h" value="{$qyConfig->externalcontact_token}" readonly/>
				<span class="btn-h btn-success-h mar-20-h" onclick="ecopyToken()">复制</span>
			</div>
			<div class="flex-h form-row-h">
				<label class="label-required-h">EncodingAESKey:</label>
				<input type="text" id="eEncodingAESKey" class="input-required-h" value="{$qyConfig->externalcontact_aes}" readonly/>
				<span class="btn-h btn-success-h mar-20-h" onclick="ecopyEncodingAESKey()">复制</span>
			</div>
		</div>
		<div class="main-container-h">
			<h4 class="title-h">通讯录接收事件服务器配置</h4>
			<div class="flex-h form-row-h">
				<label class="label-required-h">URL:</label>
				<input type="text" id="uUrl" class="input-required-h" value="{$h->get_http_server_name()}/Addons/QyWechat/Api/Callback/Users/index.html" readonly/>
				<span class="btn-h btn-success-h mar-20-h" onclick="ucopyUrl()">复制</span>
			</div>
			<div class="flex-h form-row-h">
				<label class="label-required-h">Token:</label>
				<input type="text" id="uToken" class="input-required-h" value="{$qyConfig->user_tokent}" readonly/>
				<span class="btn-h btn-success-h mar-20-h" onclick="ucopyToken()">复制</span>
			</div>
			<div class="flex-h form-row-h">
				<label class="label-required-h">EncodingAESKey:</label>
				<input type="text" id="uEncodingAESKey" class="input-required-h" value="{$qyConfig->user_aes}" readonly/>
				<span class="btn-h btn-success-h mar-20-h" onclick="ucopyEncodingAESKey()">复制</span>
			</div>
		</div>
		<div class="form-btn-container-h pl-130-h pb-100-h pt-40-h">
			<button class="btn-h btn-success-h mar-20-h" type="button" onclick="tijiao()">提交</button>
			<button class="btn-h btn-danger-h mar-20-h" type="button" onclick="javascript:window.history.go(-1);">返回</button>
			<button class="btn-h btn-default-h mar-20-h" type="button" onclick="javascript:window.history.go(-1);">取消</button>
		</div>
		</form>
	</div>
	
</body>
<script src="/layui/layui.js"></script>
<script src="/js/ajax.js"></script>
<script type="text/javascript">
	function tijiao(){
		$('.help-inline').remove();
		var cansv= true;
		$('#form1').find('input[type="text"]').filter('[required="required"]').each(function(){
			if($.trim($(this).val())==''){
				cansv = false;
				var ntip = $('<span class="help-inline" style="color:red">该项内容不能为空</span>');
				$(this).after(ntip.show());
				$(this).one('blur',function(){
		            ntip.remove();
		        });
			}
		});
		
		if(cansv){
			//$('#form1').submit();//验证成功进行表单提交
			var formData = $('#form1').serialize();	
			myAjaxPost(false, true, '', formData, function (resp) {
				if (resp.status == 'success') {
					tusi(resp.msg);
					setTimeout(function(){ 
						location.reload(); 
					},2000);
				}else{
					alert(resp.msg);
				}
			});
		} 
		
	}
</script>
<script>
function upd(){
	$("#qy_wechat_configcorp_id").removeAttr('disabled');
	$("#qy_wechat_configcorp_id").select();
	$("#one").hide();
	$("#tow").show();
}
function upd_d(){
	var id = $("#qy_wechat_configcorp_id").val();
	myAjaxPost(false, true, 'set_id.html', { id:id}, function (resp) {
		if (resp.status == 'success') {
			tusi(resp.msg);
			$('#qy_wechat_configcorp_id').attr("disabled","disabled");
			$("#one").show();
			$("#tow").hide();
		}else{
			alert(resp.msg);
		}
	});
}
function ecopyUrl(){
	var e = document.getElementById("eUrl"); 
    e.select(); // 选择对象 
    document.execCommand("Copy"); // 执行浏览器复制命令
}
function ecopyToken(){
	var e = document.getElementById("eToken"); 
    e.select(); // 选择对象 
    document.execCommand("Copy"); // 执行浏览器复制命令
}
function ecopyEncodingAESKey(){
	var e = document.getElementById("eEncodingAESKey"); 
    e.select(); // 选择对象 
    document.execCommand("Copy"); // 执行浏览器复制命令
}
function ucopyUrl(){
	var e = document.getElementById("uUrl"); 
    e.select(); // 选择对象 
    document.execCommand("Copy"); // 执行浏览器复制命令
}
function ucopyToken(){
	var e = document.getElementById("uToken"); 
    e.select(); // 选择对象 
    document.execCommand("Copy"); // 执行浏览器复制命令
}
function ucopyEncodingAESKey(){
	var e = document.getElementById("uEncodingAESKey"); 
    e.select(); // 选择对象 
    document.execCommand("Copy"); // 执行浏览器复制命令
}

$('.public_tipSetting_contaienr svg').click(function(){
			$('.public_tipSetting_contaienr').hide();
		})
</script>
</html>